package com.pangus.ims.apiRm.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pangus.common.dto.ApiRequest;
import com.pangus.common.dto.ApiResponse;
import com.pangus.common.dto.EditDataResult;
import com.pangus.common.dto.JqGridRequest;
import com.pangus.common.dto.JqGridResponse;
import com.pangus.common.sys.dto.domain.LogDto;
import com.pangus.common.sys.utils.CheckUtils;
import com.pangus.common.sys.utils.ParamUtils;
import com.pangus.common.sys.utils.PartnerCodeHolder;
import com.pangus.ims.apiRm.dto.WmsApiRequestCount;
import com.pangus.ims.apiRm.dto.WmsErpStockDto;
import com.pangus.ims.apiRm.dto.WmsResponseCommonForm;
import com.pangus.ims.apiRm.dto.WmsRmaDto;
import com.pangus.ims.apiRm.dto.WmsShipDto;
import com.pangus.ims.apiRm.service.WmsAliasGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsAsnGetDataApiService;
import com.pangus.ims.apiRm.service.WmsBomGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsCustGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsDeptGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsMoGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsMoHandGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsMtrlGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsOAProjectService;
import com.pangus.ims.apiRm.service.WmsOrderMtrlGetDataApiService;
import com.pangus.ims.apiRm.service.WmsOrderMtrlThreadGetDataApiService;
import com.pangus.ims.apiRm.service.WmsPoGetDataApiService;
import com.pangus.ims.apiRm.service.WmsProdSellGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsRmaGetDataApiService;
import com.pangus.ims.apiRm.service.WmsShipGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsStockGetDataApiService;
import com.pangus.ims.apiRm.service.WmsStoreGetDataApiServiceTask;
import com.pangus.ims.apiRm.service.WmsSupGetDataApiServiceTask;
import com.pangus.ims.bs.dto.domain.BsAliasDto;
import com.pangus.ims.bs.dto.domain.BsBomMtrlDto;
import com.pangus.ims.bs.dto.domain.BsCustDto;
import com.pangus.ims.bs.dto.domain.BsDeptDto;
import com.pangus.ims.bs.dto.domain.BsMnMtrlDto;
import com.pangus.ims.bs.dto.domain.BsMtrlDto;
import com.pangus.ims.bs.dto.domain.BsStoreDto;
import com.pangus.ims.bs.dto.domain.BsSupDto;
import com.pangus.ims.bs.dto.domain.BsWplanMnMtrlDto;
import com.pangus.ims.bs.form.BsWplanForm;
import com.pangus.ims.wms.dto.domain.WmsMnDto;
import com.pangus.ims.wms.form.WmsRoMtrlDtForm;
import com.pangus.ims.wms.service.WmsApiRequestCountService;
import com.pangus.ims.wms.utils.IpUtils;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/getdataapi")
public class WmsRmGetDataApiController {
	
	private final Logger logger = LoggerFactory.getLogger(WmsRmGetDataApiController.class);
	
	@Autowired
	private WmsSupGetDataApiServiceTask supGetDataApiService;
	
	@Autowired
	private WmsCustGetDataApiServiceTask custGetDataApiService;
	
	@Autowired
	private WmsMtrlGetDataApiServiceTask mtrlGetDataApiService;
	
	@Autowired
	private WmsStoreGetDataApiServiceTask storeGetDataApiService;
	
	@Autowired
	private WmsDeptGetDataApiServiceTask deptGetDataApiService;
	
	@Autowired
	private WmsAliasGetDataApiServiceTask aliasGetDataApiService;
	
	@Autowired
	private WmsMoGetDataApiServiceTask moGetDataApiService;
	
	@Autowired
	private WmsShipGetDataApiServiceTask shipGetDataApiService;
	
	@Autowired
	private WmsPoGetDataApiService poGetDataApiService;
	
	@Autowired
	private WmsAsnGetDataApiService asnGetDataApiService;
	
	@Autowired
	private WmsMoHandGetDataApiServiceTask moHandGetDataApiService;
	
	@Autowired
	private WmsOrderMtrlGetDataApiService orderMtrlGetDataApiService;
	
	@Autowired
	private WmsOrderMtrlThreadGetDataApiService wmsOrderMtrlThreadGetDataApiService;
	
	@Autowired
	private WmsBomGetDataApiServiceTask bomGetDataApiService;
	
	@Autowired
	private WmsStockGetDataApiService stockGetDataApiService;
	
	@Autowired
	private WmsRmaGetDataApiService rmaGetDataApiService;
	
	@Autowired
	private WmsApiRequestCountService wmsApiRequestCountService;
	
	@Autowired
	private  WmsProdSellGetDataApiServiceTask wmsProdSellGetDataApiService;
	
	@Autowired
	private WmsOAProjectService wmsOAProjectService;
	
	@ApiOperation(value = "获取供应商信息", httpMethod = "POST")
	@ApiImplicitParam(value = "bsSupDto", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getSup" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsSupDto>> getSup(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return supGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取供应商信息", httpMethod = "POST")
	@RequestMapping(value = { "/getDefaultSup" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>  getDefaultSup(HttpServletRequest request) {
		EditDataResult<String>   result = new EditDataResult<String>  ();
		String methodName = "getDefaultSup";
       checkEditResult(result,request, methodName,10);
		if("1".equals(result.getResultCode())) {
			ApiResponse<List<BsSupDto>> resultApiResponse = supGetDataApiService.getData();
			result.setResultCode(resultApiResponse.getResultCode());
			result.setResultMsg(resultApiResponse.getResultMsg());
			result.setCount(resultApiResponse.getCount());
			if("400".equals(resultApiResponse.getResultCode())) {
				rollBackData(result);
			}
		}else {
			return result;
		}
		return result;
	}
	
	@ApiOperation(value = "获取客户信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getCust" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsCustDto>> getCust(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return custGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取客户信息", httpMethod = "POST")
	@RequestMapping(value = { "/getDefaultCust" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>  getDefaultCust(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsCustDto>> resultApiResponse = custGetDataApiService.getData();
		result.setResultCode(resultApiResponse.getResultCode());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setCount(resultApiResponse.getCount());
		return result;
	}
	
	@ApiOperation(value = "获取物料信息", httpMethod = "POST")
	@ApiImplicitParam(value = "BsMtrlDto", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsMtrlDto>> getMtrl(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return mtrlGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取物料信息", httpMethod = "POST")
	@ApiImplicitParam(value = "BsMtrlDto", required = true, dataType = "BsMtrlDto")
	@RequestMapping(value = { "/getDefaultMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>  getDefaultMtrl(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsMtrlDto>> resultApiResponse = mtrlGetDataApiService.getData();
		result.setResultCode(resultApiResponse.getResultCode());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setCount(resultApiResponse.getCount());
		return result;
	}
	
	@ApiOperation(value = "快速获取物料信息", httpMethod = "POST")
	@ApiImplicitParam(value = "BsMtrlDto", required = true, dataType = "BsMtrlDto")
	@RequestMapping(value = { "/getLastMonthMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>  getLastMonthMtrl(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsMtrlDto>> resultApiResponse = mtrlGetDataApiService.getLastMonthData();
		result.setResultCode(resultApiResponse.getResultCode());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setCount(resultApiResponse.getCount());
		return result;
	}
	
	@ApiOperation(value = "获取仓库信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getStore" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsStoreDto>> getStore(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return storeGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取仓库信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getDefaultStore" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>  getDefaultStore(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsStoreDto>> resultApiResponse = storeGetDataApiService.getData();
		result.setResultCode(resultApiResponse.getResultCode());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setCount(resultApiResponse.getCount());
		return result;
	}
	
	@ApiOperation(value = "获取部门信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getDept" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsDeptDto>>  getDept(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
			return  deptGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取部门信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getDefaultDept" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String> getDefaultDept(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsDeptDto>> resultApiResponse = deptGetDataApiService.getData();
		result.setResultCode(resultApiResponse.getResultCode());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setCount(resultApiResponse.getCount());
		return result;
	}
	
	@ApiOperation(value = "获取账户信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getAlias" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsAliasDto>> getAlias(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return aliasGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "无参获取账户信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getDefaultAlias" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String> getAlias(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		ApiResponse<List<BsAliasDto>> resultApiResponse = aliasGetDataApiService.getData();
		result.setCount(resultApiResponse.getCount());
		result.setResultMsg(resultApiResponse.getResultMsg());
		result.setResultCode(resultApiResponse.getResultCode());
		return result;
	}
	
	@ApiOperation(value = "获取ERP发货通知单信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getShip" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<WmsShipDto>> getShip(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return shipGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取采购订单信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getPo" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<WmsRoMtrlDtForm>> getPo(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return poGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取ASN信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getAsn" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<WmsRoMtrlDtForm>> getAsn(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return asnGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "手动获取ERP工单信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getMoHand" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsWplanForm>> handGetMo(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return moHandGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取ERP工单物料需求信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getOrderMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsWplanMnMtrlDto>> getOrderMtrl(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return orderMtrlGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取ERP 全部BOM信息", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getDefaultBom" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public EditDataResult<String>   getDefaultBom(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		String methodName = "getDefaultBom";
       checkEditResult(result,request, methodName,15);
		if("1".equals(result.getResultCode())) {
			ApiResponse<List<BsBomMtrlDto>> resultApiResponse = bomGetDataApiService.getData();
			result.setCount(resultApiResponse.getCount());
			result.setResultMsg(resultApiResponse.getResultMsg());
			result.setResultCode(resultApiResponse.getResultCode());
			if("400".equals(resultApiResponse.getResultCode())) {
				rollBackData(result);
			}
		}else {
			return result;
		}
		return result;
	}
	
	@ApiOperation(value = "获取ERP BOM信息(", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getBom" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<BsBomMtrlDto>> getBom(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return bomGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取ERP工单物料需求信息(", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getStock" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public JqGridResponse<WmsErpStockDto> getStock(@RequestBody JqGridRequest<WmsErpStockDto> jqRequest, HttpServletRequest request){
		return stockGetDataApiService.erpGetData(jqRequest);
	}
	
	@ApiOperation(value = "获取RMA信息(", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getRma" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public ApiResponse<List<WmsRmaDto>> getRma(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return rmaGetDataApiService.getData(apiRequest);
	}
	
	@ApiOperation(value = "获取前一周的ERP工单物料需求信息", httpMethod = "POST")
	@RequestMapping(value = { "/getLastWeekOrderMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public  EditDataResult<String>  getLastWeekOrderMtrl(HttpServletRequest request){
		EditDataResult<String>   result = new EditDataResult<String>  ();
		String methodName = "getLastWeekOrderMtrl";
        checkEditResult(result,request, methodName,8);
		if("1".equals(result.getResultCode())) {
			wmsOrderMtrlThreadGetDataApiService.toOrderMtrl();
			result.setResultCode("S1001000");
		}else {
			return result;
		}
		return result;
	}
	
	@ApiOperation(value = "获取发货通知单信息", httpMethod = "POST")
	@RequestMapping(value = { "/getProdSell" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public synchronized ApiResponse<List<BsMnMtrlDto>>  getProdSell(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
		return wmsProdSellGetDataApiService.interfaceGetData(apiRequest); 
	}
	
//	@ApiOperation(value = "获取发货通知单信息物流信息", httpMethod = "POST")
//	@RequestMapping(value = { "/getProdSellShip" }, produces = MediaType.APPLICATION_JSON_VALUE)
//	public synchronized ApiResponse<List<WmsMnDto>>  getProdSellShip(@RequestBody ApiRequest<Map<String,String>> apiRequest, HttpServletRequest request){
//		return wmsProdSellGetDataApiService.interfaceGetDataForShip(apiRequest); 
//	}	
	
	/**
	 * 回滚数据
	 * @param resultApiResponse
	 * @param result
	 */
	public void rollBackData(EditDataResult<String>  result){
				Map<String, Object> map = result.getExtend();
				if("add".equals(map.get("type"))) {//新增还原
					WmsApiRequestCount dtoApiRequestCount = new WmsApiRequestCount();
					WmsApiRequestCount oldApiRequestCount = (WmsApiRequestCount)map.get("data");
					dtoApiRequestCount.setId(oldApiRequestCount.getId());
					wmsApiRequestCountService.delete(dtoApiRequestCount);
				}else {//更新还原
					WmsApiRequestCount wmsApiRequestCount = (WmsApiRequestCount)map.get("data");
					wmsApiRequestCount.setUpdatedDate((Date)map.get("time"));
					wmsApiRequestCount.setRequestCount(wmsApiRequestCount.getRequestCount()-1);
					wmsApiRequestCountService.updateByPrimaryKeyNotNull(wmsApiRequestCount);
				}
	}
	
	/**
	 * 检测请求信息数据
	 * @param result
	 * @param request
	 * @param methodName
	 */
	public void checkEditResult(EditDataResult<String>result,HttpServletRequest request,String methodName,Integer diffMin) {
		   ParamUtils paramUtils = new ParamUtils(request);
		 WmsApiRequestCount requestCount =new WmsApiRequestCount();
		   String ip = IpUtils.getIpAddr(request);
	        requestCount.setRequestIp(ip);
	        requestCount.setRequestMethod(methodName);
			wmsApiRequestCountService.checkAndUpDateIpCount(paramUtils, requestCount,result,diffMin);
	}
	
	
	/**
	 * 检测请求信息数据
	 * @param result
	 * @param request
	 * @param methodName
	 */
	public void checkEditResultByAuto(EditDataResult<String>result,String methodName,Integer diffMin) {
		 WmsApiRequestCount requestCount =new WmsApiRequestCount();
	        requestCount.setRequestIp("127.0.0.1");
	        requestCount.setRequestMethod(methodName);
			wmsApiRequestCountService.checkAndUpDateIpCount(buildByInterFace(), requestCount,result,diffMin);
	}
	
	
	//以下为定时任务调度使用方法
	public void startJobForSup() throws Exception{
		supGetDataApiService.startJobForSup();
	}
	
	public void startJobForMtrl() throws Exception{
		mtrlGetDataApiService.startJobForMtrl();
	}
	
	public void startJobForStore() throws Exception{
		storeGetDataApiService.getData();
	}
	
	public void startJobForCust() throws Exception{
		custGetDataApiService.getData();
	}
	
	public void startJobForDept() throws Exception{
		deptGetDataApiService.getData();
	}
	
	public void startJobForAlias() throws Exception{
		aliasGetDataApiService.getData();
	}
	
	public void startJobForGetBom() throws Exception{
		bomGetDataApiService.getData();
	}
	 public synchronized void startJobForMo() throws Exception{
			//早上7:30点，中午11:30点，晚上19:30点同步三次
		 	EditDataResult<String>   result = new EditDataResult<String>  ();
			logger.info("定时获取工单开始："+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
			result = moGetDataApiService.getData(result);
	 }
	
	public void startJobForMoMtrl() throws Exception{
		//早上8点，中午12点，晚上8点同步三次
		EditDataResult<String>   result = new EditDataResult<String>  ();
		String methodName = "getLastWeekOrderMtrl";
		checkEditResultByAuto(result,methodName,8);
		if("1".equals(result.getResultCode())) {
			logger.info("定时获取工单物料开始："+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
			wmsOrderMtrlThreadGetDataApiService.toOrderMtrl();
		}else {
			
		}
	}
	
	@ApiOperation(value = "获取发货通知单信息", httpMethod = "POST")
	@RequestMapping(value = { "/startJobForProdSell" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public synchronized void startJobForProdSell() throws Exception {
		// 早上7:30点，中午11:30点，晚上19:30点同步三次
		EditDataResult<String> result = new EditDataResult<String>();
		logger.info("定时获取出货通知单开始：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		result = wmsProdSellGetDataApiService.getData(result);
	}
	
//	@ApiOperation(value = "拉取发货通知单信息-发送短信", httpMethod = "POST")
//	@RequestMapping(value = { "/startJobForProdSellShip" }, produces = MediaType.APPLICATION_JSON_VALUE)
//	public synchronized void startJobForProdSellShip() throws Exception {
//		EditDataResult<String> result = new EditDataResult<String>();
//		logger.info("拉取发货通知单信息-发送短信：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//		result = wmsProdSellGetDataApiService.getDataSms(result);
//	}	
	
	@ApiOperation(value = "获取oa研发子项", httpMethod = "POST")
	@RequestMapping(value = { "/startJobForOaProject" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public synchronized void startJobForOaProject() throws Exception {
		wmsOAProjectService.getData();
	}
	
	
	public static ParamUtils buildByInterFace() {
		ParamUtils paramUtils = new ParamUtils();
		paramUtils.setLocale(new Locale("zh", "CN"));
		paramUtils.setUserFactCode("102");
		paramUtils.setUserId("X299841286054154240");
		paramUtils.setUserCode("super_admin");
		LogDto logDto = new LogDto();
		logDto.setUserCode("super_admin");
		logDto.setCreatedDate(new Date());
		paramUtils.setLogDto(logDto);
		CheckUtils checkUtils=new CheckUtils();
		paramUtils.setCheckUtils(checkUtils);
		PartnerCodeHolder.setPartnerCode("PGPG");
		return paramUtils;
	}
	
	@ApiOperation(value = "更新每一个物料", httpMethod = "POST")
	@ApiImplicitParam(value = "apiRequest", required = true, dataType = "ApiRequest<Map<String,String>>")
	@RequestMapping(value = { "/getEveryMtrl" }, produces = MediaType.APPLICATION_JSON_VALUE)
	public void getEveryMtrl(HttpServletRequest request){
		mtrlGetDataApiService.getEveryMtrl();
	}
}
